#include "operationPages.h"
#include <iostream>

OperationPage::OperationPage(std::vector<QString> _names, QWidget *_parent) : QWidget(_parent){
    image1 = image2 = 0;

	QLabel* image1Label = new QLabel(tr("Imagem 1: "));
	QLabel* image2Label = new QLabel(tr("Imagem 2: "));

    QComboBox *image1ComboBox = new QComboBox;
    QComboBox *image2ComboBox = new QComboBox;

    for(unsigned int i = 0; i < _names.size(); i++){
        image1ComboBox->addItem(_names.at(i));
        image2ComboBox->addItem(_names.at(i));
    }

    connect(image1ComboBox, SIGNAL(activated(int)), this, SLOT(changeImage1(int)));
    connect(image2ComboBox, SIGNAL(activated(int)), this, SLOT(changeImage2(int)));

//	tryItButton = new QPushButton(tr("Testar"),this);
//    connect(tryItButton, SIGNAL(clicked()), this, SLOT(tryIt()));

    QHBoxLayout *imageLayout = new QHBoxLayout;
    imageLayout->addWidget(image1Label);
    imageLayout->addWidget(image1ComboBox);
	imageLayout->addStretch(2);
    imageLayout->addWidget(image2Label);
    imageLayout->addWidget(image2ComboBox);
	imageLayout->addStretch(100);

//    QHBoxLayout *buttomLayout = new QHBoxLayout;
//	buttomLayout->addWidget(tryItButton, 0, Qt::AlignRight);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(imageLayout);
	mainLayout->addStretch();
//    mainLayout->addLayout(buttomLayout);
//	mainLayout->addStretch();

    setLayout(mainLayout);
}

void OperationPage::changeImage1(int _i){
    image1 = _i;
    done();
}

void OperationPage::changeImage2(int _i){
    image2 = _i;
    done();
}

//void OperationPage::tryIt(){
//    tryItButton->setEnabled(false);
//    done();
//}
//
//void OperationPage::tryItAgain(){
//    tryItButton->setEnabled(true);
//}

int OperationPage::getImage1(){
    return image1;
}

int OperationPage::getImage2(){
    return image2;
}
